function main
clc,clear,close all
x=[1:4]
% size(x)
% dim=find(size(x)~=1,1)
% size(x,dim)
mean(x)
end

function y = mean(x,dim)
if nargin==1
    dim=find(size(x)~=1,1);
    if isempty(dim), dim=1; end
    y=sum(x)/size(x,dim)
else
    y=sum(x,dim)/size(x,dim);
end
end

